package com.zzedu.controller;

import com.zzedu.common.annotation.Log;
import com.zzedu.common.core.controller.BaseController;
import com.zzedu.common.core.domain.AjaxResult;
import com.zzedu.common.core.page.TableDataInfo;
import com.zzedu.common.enums.BusinessType;
import com.zzedu.common.utils.ServletUtils;
import com.zzedu.common.utils.poi.ExcelUtil;
import com.zzedu.domain.ZzFeedback;
import com.zzedu.dto.ZzFeedbackDTO;
import com.zzedu.service.IZzFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 信息反馈Controller
 * 
 * @author Mr.Wang
 * @date 2025-03-06
 */
@RestController
@RequestMapping("/message/feedback")
public class ZzFeedbackController extends BaseController
{
    @Autowired
    private IZzFeedbackService zzFeedbackService;

    /**
     * 查询信息反馈列表
     */
    @PreAuthorize("@permission.hasAnyPermissions('message:feedback:query')")
    @RequestMapping("/list")
    public TableDataInfo list(@RequestBody ZzFeedbackDTO zzFeedback)
    {
        return getDataTable(zzFeedbackService.page(zzFeedback.getPageDTO(),zzFeedbackService.buildQuery(zzFeedback)));
    }

    /**
     * 导出信息反馈列表
     */
    @PreAuthorize("@permission.hasAnyPermissions('message:feedback:export')")
    @Log(title = "信息反馈", businessType = BusinessType.EXPORT)
    @RequestMapping("/export")
    public void export(ZzFeedbackDTO zzFeedback)
    {
        List<ZzFeedback> list = zzFeedbackService.list(zzFeedbackService.buildQuery(zzFeedback));
        ExcelUtil<ZzFeedback> util = new ExcelUtil<ZzFeedback>(ZzFeedback.class);
        util.exportExcel(ServletUtils.getResponse(),list, "信息反馈数据");
    }




    /**
     * 新增保存信息反馈
     */
    @PreAuthorize("@permission.hasAnyPermissions('message:feedback:add')")
    @Log(title = "信息反馈", businessType = BusinessType.INSERT)
    @RequestMapping("/add")
    public AjaxResult addSave(@Validated @RequestBody ZzFeedback zzFeedback)
    {
        return toAjax(zzFeedbackService.save(zzFeedback));
    }



    /**
     * 获取信息反馈详细信息
     */
    @PreAuthorize("@permission.hasAnyPermissions('message:feedback:query')")
    @RequestMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zzFeedbackService.getById(id));
    }


    /**
     * 修改保存信息反馈
     */
    @PreAuthorize("@permission.hasAnyPermissions('message:feedback:edit')")
    @Log(title = "信息反馈", businessType = BusinessType.UPDATE)
    @RequestMapping("/edit")
    public AjaxResult editSave(@Validated @RequestBody ZzFeedback zzFeedback)
    {
        return toAjax(zzFeedbackService.updateById(zzFeedback));
    }

    /**
     * 删除信息反馈
     */
    @PreAuthorize("@permission.hasAnyPermissions('message:feedback:remove')")
    @Log(title = "信息反馈", businessType = BusinessType.DELETE)
	@RequestMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(zzFeedbackService.removeBatchByIds(ids));
    }
}
